package io;

import java.io.BufferedOutputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;

/**
 * 对象流应用
 */
public class ObjectOutputStreamDemo01 {
    public static void main(String[] args) throws IOException {
        Message m1 = new Message(1, "传奇老师病了",  "做了个小手术");
        //1.构建流对象
        ObjectOutputStream oos =
                new ObjectOutputStream(
                                   new FileOutputStream("message.txt"));
        //2.写对象(序列化)
        oos.writeObject(m1);
        System.out.println("序列化OK");
        //3.关闭流对象
        oos.close();
    }
}
